package main.java.templatemethod;

import main.java.templatemethod.httpbean.MyRequest;
import main.java.templatemethod.httpbean.MyResponse;

/**
 * @author xin麒
 * @date 2023/2/7 11:46
 */
public abstract class AbstractShopService {
    public MyResponse handler(MyRequest myRequest){
        return handlerTempPlate(myRequest);
    }
    MyResponse handlerTempPlate(MyRequest myRequest){//这个方法相当于是模板
        queryShopInfo();//1、查询商品信息

        signature();//2、加签
        httpRequest();//3、选择http请求的方式

        verifySignature();//4、验签
        return new MyResponse();

    }

    private void verifySignature(){
        System.out.println("4、验签");
    }

    private void httpRequest(){
        System.out.println("3、选择http请求的方式");
        System.out.println("代理模式："+isRequestByProxy());//是否为代理模式
    }

    protected abstract boolean isRequestByProxy();

    private void signature(){
        System.out.println("2、加签");

    }


    private void queryShopInfo(){
        System.out.println("1、查询商品信息");

    }

}
